package com.augurit.wf.bi.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.augurit.wf.bi.web.form.WfTemplateMgmtPrivForm;
import com.augurit.wf.common.entity.WfTemplateMgmtPriv;

public class WfTemplateMgmtPrivConvertor {
	public static WfTemplateMgmtPrivForm convertVoToForm(WfTemplateMgmtPriv entity) {
		if(entity != null) {
			WfTemplateMgmtPrivForm form = new WfTemplateMgmtPrivForm();
			form.setId(entity.getId());
			form.setTemplateId(entity.getTemplateId());
			form.setUserId(entity.getUserId());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(WfTemplateMgmtPrivForm form, WfTemplateMgmtPriv entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			entity.setTemplateId(form.getTemplateId());
			entity.setUserId(form.getUserId());
		}
	}
	
	public static List<WfTemplateMgmtPrivForm> convertVoListToFormList(List<WfTemplateMgmtPriv> wfTemplateMgmtPrivList) {
		if(wfTemplateMgmtPrivList != null && wfTemplateMgmtPrivList.size() > 0) {
			List<WfTemplateMgmtPrivForm> wfTemplateMgmtPrivFormList = new ArrayList();
			for(int i=0; i<wfTemplateMgmtPrivList.size(); i++) {
				wfTemplateMgmtPrivFormList.add(convertVoToForm(wfTemplateMgmtPrivList.get(i)));
			}
			return wfTemplateMgmtPrivFormList;
		}
		return null;
	}
	
	public static List<Map> convertVoListToMapList(List<WfTemplateMgmtPriv> wfTemplateMgmtPrivList) {
		if(wfTemplateMgmtPrivList != null && wfTemplateMgmtPrivList.size() > 0) {
			List<Map> mapList = new ArrayList();
			for(int i=0; i<wfTemplateMgmtPrivList.size(); i++) {
				WfTemplateMgmtPriv entity = wfTemplateMgmtPrivList.get(i);
				Map<String, String> map = new HashMap();

				map.put("id", entity.getId() == null ? "" : entity.getId().toString());
				map.put("templateId", entity.getTemplateId() == null ? "" : entity.getTemplateId().toString());
				map.put("userId", entity.getUserId() == null ? "" : entity.getUserId().toString());
				
				mapList.add(map);
			}
			return mapList;
		}
		return null;
	}
	
	public static List<WfTemplateMgmtPriv> convertFormListToVoList(List<WfTemplateMgmtPrivForm> wfTemplateMgmtPrivFormList) {
		if(wfTemplateMgmtPrivFormList != null && wfTemplateMgmtPrivFormList.size() > 0) {
			List<WfTemplateMgmtPriv> wfTemplateMgmtPrivList = new ArrayList();
			for(int i=0; i<wfTemplateMgmtPrivFormList.size(); i++) {
				WfTemplateMgmtPriv wfTemplateMgmtPriv = new WfTemplateMgmtPriv();
				convertFormToVo(wfTemplateMgmtPrivFormList.get(i), wfTemplateMgmtPriv);
				wfTemplateMgmtPrivList.add(wfTemplateMgmtPriv);
			}
			return wfTemplateMgmtPrivList;
		}
		return null;
	}
}